<%inherit file="/base.mako"/>

<%def name="content()">
	<h2>Last ${len(c.heartbeats)} Heartbeat Response (in seconds)</h2>
	<table>
		<thead>
			<tr>
				<th>Application</th>
				% for heartbeat in c.heartbeats:
					<th>${heartbeat.beat_time.strftime('%b/%d/%Y %l:%M %p')}</th>
				% endfor
			</tr>
		</thead>
		<tbody>
			% for app in c.apps:
				<tr>
					<td>${app}</td>
					% for heartbeat in c.heartbeats:
						% if app not in heartbeat.responses:
							<td>No Response</td>
						% else:
							<td>${self.render_time_diff(heartbeat.beat_time, heartbeat.responses[app].response_time)}</td>
						% endif
					% endfor
				</tr>
			% endfor
		</tbody>
	</table>
</%def>

<%def name="render_time_diff(start, end)">
	<% difference = end - start %>
	% if difference.seconds == 0:
		<span>&lt; 1</span>
	% else:
		<span>${difference.seconds}</span>
	% endif
</%def>
